package com.HomeWork;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

public class work2_Timer {
    public static boolean TwoMin(){
        boolean f=true;
        Timer timer = new Timer("我的定时器");
        Alarm2 mtt = new Alarm2();
        Date now = new Date();
        long oneMiuteLater = now.getTime() + 2*60 * 1000; // 一分钟以后。
        Date oneMiute = new Date(oneMiuteLater);
        timer.schedule(mtt, oneMiute);
        return f;
    }
}
class Alarm2 extends TimerTask {
    @Override
    public void run() {
        System.out.println("闹钟结束");
    }
}
